package sk.stuba.fiit.repka.dp.db;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import sk.stuba.fiit.repka.dp.owl.MyOWLClass;
import sk.stuba.fiit.repka.dp.owl.MyOWLDataProperty;
import sk.stuba.fiit.repka.dp.owl.MyOWLIndividual;
import sk.stuba.fiit.repka.dp.owl.MyOWLObjectProperty;
import sk.stuba.fiit.repka.dp.owl.OWLComponent;

/**
 * 
 * @author Igor Repka
 * class servers to mapping user inputs as expectations on composit web service to attributes which will be stored in database
 */
public class AttributesMapper {

	private Map<String, String> mapper;
	
	public AttributesMapper() {
		this.mapper = new HashMap<String, String>();
	}
	
	public Map<String, String> mapAttributesFromOWL(List<? extends OWLComponent> components) {
		Iterator<? extends OWLComponent> iter = components.iterator();
		while(iter.hasNext()) {
			OWLComponent comp = iter.next();
			String name = comp.getName();
			String type = "";
			if(comp instanceof MyOWLClass) {
				type = EnumUtils.ATTR_TYPE_CLASS;
				this.mapper.put(name, type);
			}
			if(comp instanceof MyOWLDataProperty) {
				type = EnumUtils.ATTR_TYPE_DATAPROP;
				this.mapper.put(name, type);
			}
			if(comp instanceof MyOWLObjectProperty) {
				type = EnumUtils.ATTR_TYPE_OBJPROP;
				this.mapper.put(name, type);
			}
			if(comp instanceof MyOWLIndividual) {
				type =EnumUtils.ATTR_TYPE_INDI;
				this.mapper.put(name, type);
			}
			if(comp.hasSubComponent()) {
				this.mapAttributesFromOWL(comp.getSubComponents());
			}
		}
		return this.mapper;
	}
}
